package com.qf.service.impl;

import com.alibaba.druid.sql.dialect.oracle.ast.OracleDataTypeIntervalYear;
import com.qf.dao.UserDao;
import com.qf.dao.impl.UserDaoImpl;
import com.qf.entity.User;
import com.qf.service.UserService;
import com.qf.util.DruidUtil;

/*
杨威
2021/9/24
10:44
*/
public class userServiceImpl implements UserService {
    UserDao userDao=new UserDaoImpl();
    @Override
    public User login(String username, String password) {
        User user = null;
        try {
            user = userDao.select(username);
            if(user!=null){
                if(!user.getPassWord().equals(password)){
                    return null;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            DruidUtil.close();
        }
        return user;
    }

    @Override
    public int updatePassWord(String username, String password) {
        DruidUtil.begin();
        int update=0;
        try {
            update = userDao.update(username, password);
            DruidUtil.commit();
        } catch (Exception e) {
            DruidUtil.rollback();
            e.printStackTrace();
        } finally {
            DruidUtil.close();
        }
        return update;
    }

}
